<template>
	<view>
		<view class="details_image">
			<u-swiper :list="image_list" height="500" mode="number" interval="3500" border-radius="0"
				indicator-pos="topRight" circular @click="imgPreview"></u-swiper>
		</view>
		<view class="details_title">
			<view class="details_title_need">需求：
				<span class="details_title_need_name">{{needinfo.demandVariety}}</span>
			</view>
<!-- 			<view class="details_title_icon">
				<u-icon :name="collect?'heart-fill':'heart'" size="60" label="收藏" label-pos="right" label-size="25" 
				 @click="addcollect()" :style="{'color':(collect?'rgba(255, 87, 51, 1)':'rgba(112, 112, 112, 1)')}">
				 </u-icon>
			</view>	 -->
		</view>
		<view class="datails_body">
			<view
				style="height: 100rpx;font-size: 30rpx;color: rgba(255, 87, 51, 1);line-height: 80rpx; border-bottom:1px solid rgba(166, 166, 166, 1);">
				需求详情
			</view>
			<view class="datails_body_text">
				<view class="datails_body_text_title">种类：</view>
				<view class="whitespace">{{needinfo.demandSpecies}}</view>
			</view>
			<view class="datails_body_text">
				<view class="datails_body_text_title">联系人：</view>
				<view class="whitespace">{{needinfo.contactInfoId}}</view>
			</view>
			<view class="datails_body_text">
				<view class="datails_body_text_title">需求重量：</view>
				<view class="whitespace">{{needinfo.demandWeight}}</view>
			</view>
		<!-- 	<view class="datails_body_text">
				<view class="datails_body_text_title">收货地址：</view>
				<view class="whitespace">{{needinfo.detailedAddress}}</view>
			</view> -->
			<view class="datails_body_text">
				<view class="datails_body_text_title">价格：</view>
				<view class="whitespace">{{needinfo.demandPrice}}</view>
			</view>
			<view class="datails_body_text">
				<view class="datails_body_text_title">备注：</view>
				<view class="whitespace">{{needinfo.remarks}}</view>
			</view>
		</view>
		<view class="dateils_foot">
			<view class="buttonview" @click="callphone()">
				<u-icon name="phone" size="48" label="联系买家" label-pos="right" label-size="25" color="#ffffff"
					label-color="#ffffff" style="align-items: center;justify-content: center;"></u-icon>
			</view>
		</view>
		<view class="adaptation"></view>

	</view>
</template>

<script>
	import {getDemandInfo} from "apis/farmer/need"
	// 商品详情页
	export default {
		data() {
			return {
				needuuid: '',
				type: "",
				collect: 0,
				image_list: [{
					image: 'https://pic.dogimg.com/2022/05/08/62776fe3ab35f.png',
					title: ""
				}],
				needinfo: {}
			}
		},
		methods: {
			//图片预览 ----- 
			imgPreview(index) {
				uni.previewImage({
					current: index,
					urls: this.image_list
				})
			},
			callphone() {
				uni.makePhoneCall({
					phoneNumber: this.needinfo.demandContactNumber
				});
			},
			/* 错误处理 */
			error(msg) {
				const that = this
				this.$showTitleModule(msg, that.goback)
			},
			async getDemandDataInfo() {
				const {code,data} = await getDemandInfo(this.type, this.needuuid)
				if(code !== 200) return this.error("数据获取失败")
				this.needinfo = data
				this.image_list = [{
					url: data['demandCover'],
					type: 'image'
				}]
			}

		},
		onLoad() {
			const {
				id,type
			} = this.$Route.query
			if (!id) return this.error("数据获取失败")
			this.needuuid = id;
			this.type = type
			this.getDemandDataInfo();
		}
	}
</script>

<style>
	@import url("demand_details.css");
</style>
